/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BUS;

import DAO.HocSinhDAO;
import DAO.HocSinh_LopDAO;
import DAO.QuyDinhDAO;
import POJO.HocSinhPOJO;
import POJO.HocSinh_LopPOJO;
import POJO.QuyDinhPOJO;
import java.util.ArrayList;

/** @author
 *  ITEC.HCMUS.EDU.VN
 *  Ngô Huy Đạt
 *  0869005
 *  nhdat.itec@gmail.com
 */
public class HocSinh_LopBUS {

    public static ArrayList<HocSinh_LopPOJO> selectHocSinh_Nam(String MaNamHoc){
        ArrayList<HocSinh_LopPOJO> list = HocSinh_LopDAO.selectHocSinh_Nam(MaNamHoc);
        return list;
    }

    public static int insert(String MaHocSinh, String MaLop){
        int error_code=1;   //thành công
        QuyDinhPOJO qd = QuyDinhDAO.selectAll();
        ArrayList<HocSinhPOJO> hslist = HocSinhDAO.selectHocSinh_Lop(MaLop);
        if(hslist.size()>=qd.getHocSinhMax()){
            error_code = 0; //vượt giới hạn
        }else{
            boolean kq = HocSinh_LopDAO.insert(MaHocSinh, MaLop);
            if(kq==false){
                error_code = -1;    //thất bại
            }
        }
        return error_code;
    }

    public static boolean delete(String MaHocSinh, String MaLop){
        boolean kq = HocSinh_LopDAO.delete(MaHocSinh, MaLop);
        return kq;
    }
    
}
